package com.tmall.testgen.client.runinspring.push.web;


import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
import java.util.EventListener;
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;

import javax.servlet.Filter;
import javax.servlet.FilterRegistration;
import javax.servlet.FilterRegistration.Dynamic;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
import javax.servlet.SessionCookieConfig;
import javax.servlet.SessionTrackingMode;
import javax.servlet.descriptor.JspConfigDescriptor;

import org.springframework.core.io.FileSystemResource;

public class TestGenMockServletContext implements ServletContext {


	private Hashtable<String,Object> attributes=new Hashtable<String,Object>();
	private Hashtable<String,String> initParams=new Hashtable<String,String>();
	
	private String targetWebAppPath;

	
	public Enumeration getInitParameterNames() {
		return initParams.keys();
	}
	
	public Enumeration getAttributeNames() {
		return attributes.keys();
	}
	
	
	public URL getResource(String arg0) throws MalformedURLException {
		try {
			return new FileSystemResource(new File(targetWebAppPath+arg0)).getURL();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	
	public InputStream getResourceAsStream(String arg0) {
		try {
			return new FileSystemResource(new File(targetWebAppPath+arg0)).getInputStream();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public Object getAttribute(String key) {
		return attributes.get(key);
	}

	
	public ServletContext getContext(String arg0) {
		return this;
	}


	
	public String getInitParameter(String key) {
		return initParams.get(key);
	}

	
	public void removeAttribute(String key) {
		attributes.remove(key);
	}

	
	public void setAttribute(String key, Object value) {
		attributes.put(key, value);
	}
	
	public void addInitParam(String key,String value){
		initParams.put(key, value);
	}
	

	
	public String getContextPath() {
		return null;
	}
	
	public int getMajorVersion() {
		return 0;
	}

	
	public String getMimeType(String arg0) {
		return null;
	}

	
	public int getMinorVersion() {
		return 0;
	}

	
	public RequestDispatcher getNamedDispatcher(String arg0) {
		return null;
	}

	
	public String getRealPath(String arg0) {
		return null;
	}

	
	public RequestDispatcher getRequestDispatcher(String arg0) {
		return null;
	}


	public void setTargetWebAppPath(String targetWebAppPath) {
		this.targetWebAppPath = targetWebAppPath;
	}
	
	public Set getResourcePaths(String arg0) {
		return null;
	}

	
	public String getServerInfo() {
		return null;
	}

	
	public Servlet getServlet(String arg0) throws ServletException {
		return null;
	}

	
	public String getServletContextName() {
		return null;
	}

	
	public Enumeration getServletNames() {
		return null;
	}

	
	public Enumeration getServlets() {
		return null;
	}

	
	public void log(String arg0) {
		
	}

	
	public void log(Exception arg0, String arg1) {
		
	}

	
	public void log(String arg0, Throwable arg1) {
		
	}

	
	public Dynamic addFilter(String arg0, String arg1) {
		
		return null;
	}

	
	public Dynamic addFilter(String arg0, Filter arg1) {
		
		return null;
	}

	
	public Dynamic addFilter(String arg0, Class<? extends Filter> arg1) {
		
		return null;
	}

	
	public void addListener(String arg0) {
		
		
	}

	
	public <T extends EventListener> void addListener(T arg0) {
		
		
	}

	
	public void addListener(Class<? extends EventListener> arg0) {
		
		
	}

	
	public javax.servlet.ServletRegistration.Dynamic addServlet(String arg0,
			String arg1) {
		
		return null;
	}

	
	public javax.servlet.ServletRegistration.Dynamic addServlet(String arg0,
			Servlet arg1) {
		
		return null;
	}

	
	public javax.servlet.ServletRegistration.Dynamic addServlet(String arg0,
			Class<? extends Servlet> arg1) {
		
		return null;
	}

	
	public <T extends Filter> T createFilter(Class<T> arg0)
			throws ServletException {
		
		return null;
	}

	
	public <T extends EventListener> T createListener(Class<T> arg0)
			throws ServletException {
		
		return null;
	}

	
	public <T extends Servlet> T createServlet(Class<T> arg0)
			throws ServletException {
		
		return null;
	}

	
	public void declareRoles(String... arg0) {
		
		
	}

	
	public ClassLoader getClassLoader() {
		
		return null;
	}

	
	public Set<SessionTrackingMode> getDefaultSessionTrackingModes() {
		
		return null;
	}

	
	public int getEffectiveMajorVersion() {
		
		return 0;
	}

	
	public int getEffectiveMinorVersion() {
		
		return 0;
	}

	
	public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() {
		
		return null;
	}

	
	public FilterRegistration getFilterRegistration(String arg0) {
		
		return null;
	}

	
	public Map<String, ? extends FilterRegistration> getFilterRegistrations() {
		
		return null;
	}

	
	public JspConfigDescriptor getJspConfigDescriptor() {
		
		return null;
	}

	
	public ServletRegistration getServletRegistration(String arg0) {
		
		return null;
	}

	
	public Map<String, ? extends ServletRegistration> getServletRegistrations() {
		
		return null;
	}

	
	public SessionCookieConfig getSessionCookieConfig() {
		
		return null;
	}

	
	public boolean setInitParameter(String arg0, String arg1) {
		
		return false;
	}

	
	public void setSessionTrackingModes(Set<SessionTrackingMode> arg0) {
		
		
	}


}
